using System;
using System.Collections.Generic;

using log4net;

using GymManager.Exception;
using GymManager.Mechanism;
using GymManager.Persistence.DAO;
using GymManager.Persistence.VO;

namespace GymManager.Business
{
    /// <summary>
    /// Class responsible by providing services regarding Student Modality
    /// </summary>
    public class StudentModalityServices
    {
        // logger instance
        private ILog _logManager = LogManager.GetLogger(typeof(StudentModalityServices));

        /// <summary>
        /// Method responsible by getting all modalities beloging to an specific student
        /// </summary>
        /// <param name="Int32">student identifier</param>
        /// <returns>IList - list of modalities belonging to an specific student</returns>
        /// <see cref="GymManager.Exception.BusinessException"/>
        public IList<StudentModality> findByStudent(Int32 studentId)
        {
            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("Begin Method");
            }

            IList<StudentModality> studentModalityList = null;

            try
            {
                // getting all student modality belonging to an specific student
                StudentModalityDAO studentModalityDAO = new StudentModalityDAO();
                studentModalityList = studentModalityDAO.findByStudent(studentId);
            }
            catch (PersistenceException)
            {
                throw new BusinessException();
            }            
            
            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("End Method");
            }

            return studentModalityList;
        }

        /// <summary>
        /// Method responsible by returning the student's monthly fee.
        /// </summary>
        /// <param name="Int32">student identifier</param>
        /// <returns>Monthly Fee value</returns>
        /// <see cref="GymManager.Exception.BusinessException"/>
        public Double getStudentMonthlyFee(Int32 studentId)
        {
            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("Begin Method");
            }

            Double monthlyFeeValue = 0;

            try
            {
                // getting all student modality belonging to an specific student
                StudentModalityDAO studentModalityDAO = new StudentModalityDAO();
                monthlyFeeValue = studentModalityDAO.getStudentMonthlyFee(studentId);
            }
            catch (PersistenceException)
            {
                throw new BusinessException();
            }

            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("End Method");
            }

            return monthlyFeeValue;
        }

     }
}
